<?php
/**
 * View parcial para campo form admin
 * @param campo
 * @param cabecalho
 * @param valor
 * @param required
 * @param hint
 * @param maxLength
 */
$campo = $this->campo;
$cabecalho = $this->cabecalho;
$valor = $this->valor;
$hint = $this->hint;
$maxLength = $this->maxLength;
?>
<script type="text/javascript">
<!--
//Utilizada para contar os caracteres de alguns input[type=text]

function contaCaracteres(input, span, max) {
	var restante = $(input).val().length;
	var contagem = $('#' + span);
	if ($(input).val().length >= max) {
		contagem.text(0);
		$(input).val($(input).val().substring(0, max));
		return;
	}
	contagem.text(max - restante);
}
$(function () {
	$('#<?php echo $campo;?>').keyup(function() {
		contaCaracteres('#<?php echo $campo;?>', 'hint', '<?php echo $maxLength;?>');
	}).keyup();

});
//-->
</script>
<label for="<?php echo $campo; ?>"><?php echo $cabecalho; ?></label>
<textarea style="height: 100px;" class="text-input large-input {validate: {required: <?php echo (isset($this->required) && $this->required == false) ? 'false' : 'true'; ?>}}" type="text" id="<?php echo $campo; ?>" name="<?php echo $campo; ?>" <?php echo (isset($maxLength)) ? "maxlength=$maxLength" : ''; ?>><?php echo $valor; ?></textarea>

<span id="hint" class="hint"></span><span> caracteres restantes.</span>